/*
	Author: Superxpdude

	Description:
	Return the vehicle and partially refund the points.

	Parameter(s):

		0: Object - Player Unit
		1: Object - Vehicle to return


	Returns:
	NOTHING
*/
// Define variables
private ["_player","_vehicle","_playerUID","_owner","_points","_type","_returnPoints"];
_player = _this select 0;
_vehicle = _this select 1;
_playerUID = getPlayerUID _player;
_owner = _vehicle getVariable ["owner", nil];
_points = pointsLogic getVariable [_playerUID, 0];
_type = toUpper (typeOf _vehicle);

// Exit if player is not the owner
if (_playerUID != _owner) exitWith {};
// Exit if vehicle is not on a vehicle pad
if (!(_vehicle in (list vehiclestore1)) AND !(_vehicle in (list vehicleStore2))) exitWith {};

switch (_type) do {
	case "B_HELI_LIGHT_01_ARMED_F" : { _returnPoints = 15 };
	case "B_HELI_ATTACK_01_F" : { _returnPoints = 50 };
	case "I_PLANE_FIGHTER_03_CAS_F" : { _returnPoints = 75 };
	case "B_PLANE_CAS_01_F" : { _returnPoints = 150 };
};

// Empty vehicle of crew
{
	_x action ["getOut", _vehicle];
} forEach (crew _vehicle);

waitUntil {(count (crew _vehicle)) == 0;};

// Lock the vehicle while we delete it
_vehicle lock 2;
deleteVehicle _vehicle;
_points = _points + _returnPoints;
pointsLogic setVariable [_playerUID, _points, true];